package hotel.meituan.oversea.biz.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import hotel.base.oversea.constant.CommonConstants;
import hotel.base.oversea.constant.MeituanConstants;
import hotel.base.oversea.constant.enums.CommonEnums;
import hotel.base.oversea.constant.enums.MtGoodsEnums;
import hotel.base.oversea.constant.enums.MtHotelEnums;
import hotel.base.oversea.dto.meituan.MtHotelGoodsDto;
import hotel.base.oversea.utils.DateUtil;
import hotel.base.oversea.utils.GsonUtils;
import hotel.base.oversea.utils.Result;
import hotel.base.oversea.utils.StringUtil;
import hotel.base.oversea.vo.meituan.request.goods.*;
import hotel.base.oversea.vo.meituan.request.room.MtHotelRealRoomVo;
import hotel.base.oversea.vo.meituan.response.goods.MtHotelGoodsInventoryParamVo;
import hotel.base.oversea.vo.meituan.response.goods.MtHotelGoodsStatusVo;
import hotel.meituan.oversea.api.entity.MtHotelActiveInfo;
import hotel.meituan.oversea.api.entity.MtHotelPriceStatisLog;
import hotel.meituan.oversea.api.vo.StatisLogVo;
import hotel.meituan.oversea.api.vo.up.response.goods.MtHotelGoodsCallbackVo;
import hotel.meituan.oversea.api.vo.up.response.hotel.MtHotelDetailVo;
import hotel.meituan.oversea.biz.config.service.RedisService;
import hotel.meituan.oversea.biz.mapper.MtHotelActiveInfoMapper;
import hotel.meituan.oversea.biz.service.MtHotelGoodsService;
import hotel.meituan.oversea.biz.service.MtHotelPriceStatisLogService;
import hotel.meituan.oversea.biz.service.MtHotelRoomNameService;
import hotel.meituan.oversea.biz.task.MeituanFindMtGoodsCheckUpDownTask;
import hotel.meituan.oversea.biz.task.MeituanGoodsPriceLibraryCallbackTask;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 美团酒店产品Controller
 *
 * @author qiuyy
 * @date 2020-05-15
 */
@Slf4j
@RestController
@RequestMapping("/mtHotelGoods")
public class MtHotelGoodsController {

    @Autowired
    private MtHotelGoodsService mtHotelGoodsService;
    @Autowired
    private MeituanGoodsPriceLibraryCallbackTask meituanGoodsPriceLibraryCallbackTask;
    @Autowired
    private RedisService redisService;

    @Autowired
    private MeituanFindMtGoodsCheckUpDownTask meituanFindMtGoodsCheckUpDownTask;

    @Autowired
    private MtHotelPriceStatisLogService mtHotelPriceStatisLogService;


    @Autowired
    private MtHotelActiveInfoMapper mtHotelActiveInfoMapper;
    /**
     *
     * 返回酒店房型和产品数据  根据缓存
     *
     * @param map
     * @return
     */
    @PostMapping("/returnMtRoomInfoByHotelId")
    @ApiOperation(value = "内部接口查询酒店物理房型信息根据一个酒店id ", notes = "必须经过auth授权")
    public Result<Object> returnMtRoomInfosByHotelId(@RequestBody Map map) {
        Long hotelId = Long.valueOf((String)map.get("hotelId"));//获取hotelID
        List<Long> hotelIdsArray = new ArrayList<>();
        hotelIdsArray.add(hotelId);//将hotelId添加到集合中
//        TimeUnit unit;
//        BlockingQueue workQueue;
//        ThreadFactory threadFactory;
        List<MtHotelRealRoomVo> oneHotelRoomsList = null;
        String roomJson = (String)redisService.get(CommonConstants.SWITCH_MT_ONE_HOTEL_ROOMS_REDIS+String.valueOf(hotelId));//2小时查询静态信息缓存酒店的物理房型信息
        if(null != roomJson){
            oneHotelRoomsList = GsonUtils.jsonToList(roomJson,MtHotelRealRoomVo.class);//不为空则转为list，返回
        }
        if(null == oneHotelRoomsList){//为空，则
            //查询接口
            Result manyHotelsRoomInfosResult = mtHotelRoomNameService.getMtHotelRoom(hotelIdsArray);//调用接口查询物理房型
            if(manyHotelsRoomInfosResult.getCode()!=CommonConstants.SUCCESS){
                return new Result<>("请求物理房型接口失败="+GsonUtils.GsonString(manyHotelsRoomInfosResult),CommonConstants.ERROR);
            }
            Map<Long,List<MtHotelRealRoomVo>> oneHotelRoomInfosDataArray = (Map<Long,List<MtHotelRealRoomVo>>)manyHotelsRoomInfosResult.getData();
            if(ObjectUtils.isEmpty(oneHotelRoomInfosDataArray)){
                log.info("内部接口查询酒店物理房型信息根据一个酒店id 还是为空 hotelid={}",hotelId);
            }else{
                oneHotelRoomsList = oneHotelRoomInfosDataArray.get(hotelId);
            }
        }
        return new Result<>(oneHotelRoomsList);
    }
    /**
     *
     * 返回酒店房型和产品数据  根据缓存
     *
     * @param map
     * @return
     */
    @PostMapping("/returnMtRoomGoodsByHotelId")
    @ApiOperation(value = "内部接口查询产品信息根据一个酒店id", notes = "必须经过auth授权")
    public Result<Object> returnMtRoomGoodsByHotelId(@RequestBody Map map) {
        //校验参数
        Long hotelId = Long.valueOf((String)map.get("hotelId"));
        List<Long> hotelIdsArray = new ArrayList<>();
        hotelIdsArray.add(hotelId);
        MtHotelDetailVo oneHotelDetail = null;
        String hotelDetailRedis = (String)redisService.get(CommonConstants.SWITCH_MT_HOTEL_DETAIL_INFO_DATA_JOB_PUSH+hotelId);
        if(null != hotelDetailRedis){
            oneHotelDetail = GsonUtils.GsonToBean(hotelDetailRedis, MtHotelDetailVo.class);
        }
        if(null ==  oneHotelDetail){
            //查询接口
            List<MtHotelDetailVo> hotelDetailArray = mtHotelRoomNameService.returnHotelDetailRoomList(hotelIdsArray);
            if(null != hotelDetailArray && hotelDetailArray.size()>0){
                oneHotelDetail = hotelDetailArray.get(0);
            }
        }
        if(null == oneHotelDetail){
            return new Result<>("酒店查询详情异常为空",CommonConstants.ERROR);
        }
        List<MtHotelRealRoomVo> oneHotelRoomsList = null;
        String roomJson = (String)redisService.get(CommonConstants.SWITCH_MT_ONE_HOTEL_ROOMS_REDIS+String.valueOf(hotelId));
        if(null != roomJson){//
            oneHotelRoomsList = GsonUtils.jsonToList(roomJson,MtHotelRealRoomVo.class);
        }
        if(null == oneHotelRoomsList){
            //查询接口(请求获取物理房型数据)
            Result manyHotelsRoomInfosResult = mtHotelRoomNameService.getMtHotelRoom(hotelIdsArray);
            if(manyHotelsRoomInfosResult.getCode()!=CommonConstants.SUCCESS){
                return new Result<>("请求物理房型接口失败="+GsonUtils.GsonString(manyHotelsRoomInfosResult),CommonConstants.ERROR);
            }
            Map<Long,List<MtHotelRealRoomVo>> oneHotelRoomInfosDataArray = (Map<Long,List<MtHotelRealRoomVo>>)manyHotelsRoomInfosResult.getData();
            oneHotelRoomsList = oneHotelRoomInfosDataArray.get(hotelId);
        }
        MtHotelGoodsChildInfoVo oneHotelGoodsVos = null;
        String rpGoodsJson = (String)redisService.get(CommonConstants.SWITCH_MT_HOTEL_RP_GOODS_INFO_DATA_JOB_PUSH+hotelId);
        if(null != rpGoodsJson){
            oneHotelGoodsVos = GsonUtils.GsonToBean(rpGoodsJson,MtHotelGoodsChildInfoVo.class);
        }
        if(null == oneHotelGoodsVos){
            Result mtGoodsResult = mtHotelGoodsService.getTendHotelGoodsInfoForJob(hotelIdsArray);
            if(mtGoodsResult.getCode()!=CommonConstants.SUCCESS){
                return new Result<>("请求Rp房型接口失败="+GsonUtils.GsonString(mtGoodsResult),CommonConstants.ERROR);
            }
            MtHotelGoodsVo mtHotelGoodsVo = null;
            if(null != mtGoodsResult.getData()){
                mtHotelGoodsVo = GsonUtils.objToBean(mtGoodsResult.getData(),MtHotelGoodsVo.class);
            }
            if(!ObjectUtils.isEmpty(mtHotelGoodsVo)){
                oneHotelGoodsVos = mtHotelGoodsVo.getHotelGoods().get(0);
            }
        }
        Result result = mtHotelGoodsService.buildSwUpGoods(oneHotelDetail, oneHotelRoomsList,oneHotelGoodsVos);
        return result;
    }

    /**
     *
     * 下游调用返回产品信息（重新构建下游需要数据结构，并且不涉及库表保存保证及时返回数据）
     *
     * @param mtHotelGoodsSpecParamVo
     * @return
     */
    @PostMapping("/getMtGoodsByHotelId")
    @ApiOperation(value = "内部接口查询产品信息根据一个酒店id", notes = "必须经过auth授权")
    public Result<Object> aspgetMtGoodsByHotelId(@RequestBody MtHotelGoodsSpecParamVo mtHotelGoodsSpecParamVo) {
        //校验参数
        Long hotelId = mtHotelGoodsSpecParamVo.getHotelId();
        String checkinDate = mtHotelGoodsSpecParamVo.getCheckinDate();
        String checkoutDate = mtHotelGoodsSpecParamVo.getCheckoutDate();
        Integer goodsType = mtHotelGoodsSpecParamVo.getGoodsType();
        //checkinDate和out 为空默认返回时间段30天
        if (null == goodsType) {
            //为空默认全日房
            mtHotelGoodsSpecParamVo.setGoodsType(MtGoodsEnums.roomDateTypeEnum.DAY.getCode());
        }
        Result result = mtHotelGoodsService.getMtGoodsByHotelId(mtHotelGoodsSpecParamVo);
        if (result.getCode() == CommonConstants.SUCCESS) {
            //保存产品信息（不在get方法里保存另起方法）// 当前返回处理了真实roomid
            List<Long> ids = new ArrayList<>();
            ids.add(hotelId);
            Result<Object> result1 = mtHotelGoodsService.buildGoodsDataNotSave(ids,"inner", (MtHotelGoodsVo) result.getData());
            return result1;
        } else {
            return result;
        }
    }

    /**
     * 产品信息返回给 飞猪
     * @param mtHotelGoodsParamVo
     * @return
     */
    @PostMapping("/getMtHotelGoodsForFg")
    @ApiOperation(value = "查询产品信息接口", notes = "必须经过auth授权")
    public Result<Object> getMtHotelGoodsForFg(@RequestBody MtHotelGoodsParamVo mtHotelGoodsParamVo) {
        //校验参数
        List<Long> hotelIds = mtHotelGoodsParamVo.getHotelIds();
        String checkinDate = mtHotelGoodsParamVo.getCheckinDate();
        String checkoutDate = mtHotelGoodsParamVo.getCheckoutDate();
        Integer goodsType = mtHotelGoodsParamVo.getGoodsType();
        //时间参数为空 默认30天
        if (StringUtils.isEmpty(checkinDate)) {
            checkinDate = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
            checkoutDate = DateUtil.formatDate(DateUtil.addDay(new Date(), 30), "yyyy-MM-dd");
        }
        if (ObjectUtils.isEmpty(goodsType) || 0 == goodsType) {
            //为空默认全日房
            goodsType = MtGoodsEnums.roomDateTypeEnum.DAY.getCode();
        }
        Result result = mtHotelGoodsService.getMtHotelGoods(null,hotelIds,checkinDate,checkoutDate,goodsType);//返回的roomId不是真实的，在save方法里会做判断和更新为真是的roomId
        if(result.getCode()==CommonConstants.SUCCESS){
            //保存产品信息（不在get方法里保存另起方法）
            return mtHotelGoodsService.buildGoodsDataNotSave(hotelIds,"pig",(MtHotelGoodsVo)result.getData());//需要真的roomId则需要再调用产品表查询
        }
        return result;
    }

    /**
     * 产品各项信息规格整理返回根据一个酒店id，涉及请求上游接口（处理返回多实体对象数据，减少实体对象嵌套）
     *
     * @param mtHotelGoodsSpecParamVo
     * @return
     */
    @PostMapping("/getCancelRuleByMtInfo")
    @ApiOperation(value = "内部接口查询产品取消根据一个酒店id", notes = "必须经过auth授权")
    public Result<Object> getCancelRuleByHotelIdGoodId(@RequestBody MtHotelGoodsSpecParamVo mtHotelGoodsSpecParamVo) {
        //校验参数
        Integer goodsId = mtHotelGoodsSpecParamVo.getGoodsId();
        if(ObjectUtils.isEmpty(goodsId)){
            return new Result<>("goodsId 不可为空",CommonConstants.REQUEST_ERROR);
        }
        Long hotelId = mtHotelGoodsSpecParamVo.getHotelId();
        if(ObjectUtils.isEmpty(hotelId)){
            return new Result<>("hotelId 不可为空",CommonConstants.REQUEST_ERROR);
        }
        String checkinDate = mtHotelGoodsSpecParamVo.getCheckinDate();
        String checkoutDate = mtHotelGoodsSpecParamVo.getCheckoutDate();
        Integer goodsType = mtHotelGoodsSpecParamVo.getGoodsType();
        //checkinDate和out 为空默认返回时间段30天
        if (null == goodsType) {
            //为空默认全日房
            mtHotelGoodsSpecParamVo.setGoodsType(MtGoodsEnums.roomDateTypeEnum.DAY.getCode());
        }
        Result result = mtHotelGoodsService.getMtGoodsByHotelId(mtHotelGoodsSpecParamVo);//产品接口获取 第三方参数为酒店id不可上送产品id
        if (result.getCode() == CommonConstants.SUCCESS) {
            MtHotelGoodsVo mtHotelGoodsVo = (MtHotelGoodsVo) result.getData();
            /*try {//// 2020-10-28 qyy 其他接口不做保存操作，查询产品校验上下线定时器做保存操作需要对比数据
                mtHotelGoodsService.saveGoodsData("inner", (MtHotelGoodsVo) result.getData());      //保存产品信息（不在get方法里保存另起方法）
            } catch (Exception e) {
                e.printStackTrace();
            }*/
            if (null != mtHotelGoodsVo && !ObjectUtils.isEmpty( mtHotelGoodsVo.getHotelGoods())) {
                for (MtHotelGoodsChildInfoVo goods : mtHotelGoodsVo.getHotelGoods()) {//当前接口上送指定酒店所以 tHotelGoodsVo.getHotelGoods()  size = 1  一个酒店
                    for (MtHotelGoodsBaseInfoVo mtHotelGoodsBaseInfoVo : goods.getGoods()) {
                        if (mtHotelGoodsBaseInfoVo.getGoodsId().equals(String.valueOf(goodsId))) {
                            return new Result<>(mtHotelGoodsBaseInfoVo.getCancelRules(), "success");
                        }
                    }
                }
            }
            return new Result<>("接口返回空"+ JSON.toJSONString(result));
        } else {
            return new Result<>("接口失败："+ JSON.toJSONString(result),CommonConstants.REQUEST_ERROR);
        }
    }

    /**
     * 该方法直接调用美团接口直接返回数， 不返回真实的房型id  直接返回接口信息（接口信息是逻辑房型id）
     *
     * Rp接口 价格可以返回价格日历，30天就返回价格集合30
     *        房态只能返回一天，不能返回房态日历
     *
     * @param mtHotelGoodsParamVo
     * @return
     */
    @PostMapping("/getMtHotelGoods")
    @ApiOperation(value = "查询产品信息接口", notes = "必须经过auth授权")
    public Result<Object> saveGetMtHotelGoods(@RequestBody MtHotelGoodsParamVo mtHotelGoodsParamVo) {
        //校验参数
        List<Long> hotelIds = mtHotelGoodsParamVo.getHotelIds();
        String checkinDate = mtHotelGoodsParamVo.getCheckinDate();
        String checkoutDate = mtHotelGoodsParamVo.getCheckoutDate();
        Integer goodsType = mtHotelGoodsParamVo.getGoodsType();
        //时间参数为空 默认30天
        if (StringUtils.isEmpty(checkinDate)) {
            checkinDate = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
            checkoutDate = DateUtil.formatDate(DateUtil.addDay(new Date(), 30), "yyyy-MM-dd");
        }
        if (null == goodsType || 0 == goodsType) {
            //为空默认全日房
            goodsType = MtGoodsEnums.roomDateTypeEnum.DAY.getCode();
        }
        Result result = mtHotelGoodsService.getMtHotelGoods(null,hotelIds,checkinDate,checkoutDate,goodsType);//返回的roomId不是真实的，在save方法里会做判断和更新为真是的roomId
        if(result.getCode()==CommonConstants.SUCCESS){
            //保存产品信息（不在get方法里保存另起方法）
            //mtHotelGoodsService.saveGoodsData(null,(MtHotelGoodsVo)result.getData());//需要真的roomId则需要再调用产品表查询
            ////// 2020-10-28 qyy 其他接口不做保存操作，查询产品校验上下线定时器做保存操作需要对比数据
        }
        return result;
    }
//
    /**
     * {\"code\":0,\"message\":\"成功\",\"partnerId\":12734,\"result\":{\"hotelGoods\":null}}
     * @param mtHotelGoodsParamVo
     * @return
     */
    @PostMapping("/apiGoodsRp")
    @ApiOperation(value = "直连-rp", notes = "必须经过auth授权")
    public Result<Object> apiGoodsRp(@RequestBody MtHotelGoodsParamVo mtHotelGoodsParamVo) {
        //接口地址:https://developer-distribution.meituan.com/distribution-open-platform/#/apiDocs/1/13/21
        //校验参数
        List<Long> hotelIds = mtHotelGoodsParamVo.getHotelIds();
        String checkinDate = mtHotelGoodsParamVo.getCheckinDate();
        String checkoutDate = mtHotelGoodsParamVo.getCheckoutDate();
        Integer goodsType = mtHotelGoodsParamVo.getGoodsType();
        //时间参数为空 默认30天
        if (StringUtils.isEmpty(checkinDate)) {
            checkinDate = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
            checkoutDate = DateUtil.formatDate(DateUtil.addDay(new Date(), 7), "yyyy-MM-dd");
        }
        if (null == goodsType || 0 == goodsType) {
            //为空默认全日房
            goodsType = MtGoodsEnums.roomDateTypeEnum.DAY.getCode();
        }
        Result result = mtHotelGoodsService.apiGoodsRp(null,hotelIds,checkinDate,checkoutDate,goodsType);//返回的roomId不是真实的，在save方法里会做判断和更新为真是的roomId
        return result;
    }

    /**
     * 爬虫需要：返回有活动的产品并保存在库表中
     * @param mtHotelGoodsParamVo
     * @return
     */
    @PostMapping("/getMtHotelGoodsSaveData")
    @ApiOperation(value = "查询产品信息接口", notes = "必须经过auth授权")
    public Result<Object> getMtHotelGoodsSaveData(@RequestBody MtHotelGoodsParamVo mtHotelGoodsParamVo) {
        //校验参数
        List<Long> hotelIds = mtHotelGoodsParamVo.getHotelIds();
        String checkinDate = mtHotelGoodsParamVo.getCheckinDate();
        String checkoutDate = mtHotelGoodsParamVo.getCheckoutDate();
        Integer goodsType = mtHotelGoodsParamVo.getGoodsType();
        //时间参数为空 默认30天
        if (StringUtils.isEmpty(checkinDate)) {
            checkinDate = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
            checkoutDate = DateUtil.formatDate(DateUtil.addDay(new Date(), 30), "yyyy-MM-dd");
        }
        if (ObjectUtils.isEmpty(goodsType) || 0 == goodsType) {
            //为空默认全日房
            goodsType = MtGoodsEnums.roomDateTypeEnum.DAY.getCode();
        }
        Result result = mtHotelGoodsService.getMtHotelGoodsFindActivity(null,hotelIds,checkinDate,checkoutDate,goodsType);//返回的roomId不是真实的，在save方法里会做判断和更新为真是的roomId
        if(result.getCode()==CommonConstants.SUCCESS){
            if(ObjectUtils.isEmpty(result.getData())){
                //返回全部没有产品信息的
                final List<MtHotelActiveInfo> mtHotelActiveInfoList = new ArrayList<>();
                hotelIds.forEach(hotelId -> {
                    MtHotelActiveInfo mtHotelActiveInfo = new MtHotelActiveInfo();
                    mtHotelActiveInfo.setIsActivityTags(2);//不存在商品酒店
                    mtHotelActiveInfo.setId(String.valueOf(hotelId).substring(0,2)+"57"+ StringUtil.getUUID());
                    mtHotelActiveInfo.setMtHotelId(String.valueOf(hotelId));
                    mtHotelActiveInfo.setCreateTime(new Date());
                    mtHotelActiveInfoList.add(mtHotelActiveInfo);
                });
                if(mtHotelActiveInfoList.size()>0){
                    int insInt = mtHotelActiveInfoMapper.insertList(mtHotelActiveInfoList);
                    log.info(">>>>>>>>>>>>【没有产品酒店信息】批量新增{}条记录!!",insInt);
                }
            }else{
                //保存产品信息（不在get方法里保存另起方法）
                mtHotelGoodsService.checkFindActivity(hotelIds,(MtHotelGoodsVo)result.getData());//需要真的roomId则需要再调用产品表查询
                ////// 2020-10-28 qyy 其他接口不做保存操作，查询产品校验上下线定时器做保存操作需要对比数据
            }

        }
        return result;
    }



    /**
     * 返回没有活动的携程酒店list
     * @param map("携程","美团")
     * @return list
     */
    @PostMapping("/getMtHotelActiveBySwitchHotelIds")
    @ApiOperation(value = "查询产品信息接口", notes = "必须经过auth授权")
    public Result<Object> getMtHotelActiveBySwitchHotelIds(@RequestBody Map<String, String> map) {

        Integer activeDay = 7; //默认7天
        //判断缓存是否存在，存在直接获取
        if(redisService.exists(MeituanConstants.MEITUAN_FIND_ACTIVE_GOODS_DAY)){
            activeDay = (Integer) redisService.get(MeituanConstants.MEITUAN_FIND_ACTIVE_GOODS_DAY);
        }

        List<Long> hotelIds = new ArrayList<>();

        if(!map.isEmpty() && map.size()>0){
            for(Map.Entry<String, String> entry : map.entrySet()){
                String switchHotelId = entry.getKey();
                String meituanHotelId = entry.getValue();
                hotelIds.add(Long.valueOf(meituanHotelId));
            }
        }else{
            return new Result<>(CommonEnums.DATA_NULL);
        }

        MtHotelGoodsParamVo mtHotelGoodsParamVo = new MtHotelGoodsParamVo();
        //校验参数
        String checkinDate = mtHotelGoodsParamVo.getCheckinDate();
        String checkoutDate = mtHotelGoodsParamVo.getCheckoutDate();
        Integer goodsType = mtHotelGoodsParamVo.getGoodsType();
        //时间参数为空 默认7天
        if (StringUtils.isEmpty(checkinDate)) {
            checkinDate = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
            checkoutDate = DateUtil.formatDate(DateUtil.addDay(new Date(), activeDay), "yyyy-MM-dd");
        }
        if (ObjectUtils.isEmpty(goodsType) || 0 == goodsType) {
            //为空默认全日房
            goodsType = MtGoodsEnums.roomDateTypeEnum.DAY.getCode();
        }
        Result result = mtHotelGoodsService.getMtHotelGoodsFindActivity(null,hotelIds,checkinDate,checkoutDate,goodsType);//返回的roomId不是真实的，在save方法里会做判断和更新为真是的roomId
        if(result.getCode()==CommonConstants.SUCCESS){
            //保存产品信息（不在get方法里保存另起方法）
            result = mtHotelGoodsService.checkFindNoActivity(null,(MtHotelGoodsVo)result.getData(),map);//需要真的roomId则需要再调用产品表查询
            ////// 2020-10-28 qyy 其他接口不做保存操作，查询产品校验上下线定时器做保存操作需要对比数据
        }else {
            return new Result<>(CommonEnums.DATA_NULL);
        }
        return result;
    }

    /**
     * 查询产品库存 0 或1 不能返回具体数量
     * @param mtHotelGoodsInventoryParamVo
     * @return
     */
    @PostMapping("/getMtHotelGoodsInventory")
    @ApiOperation(value = "查询产品库存信息接口", notes = "必须经过auth授权")
    public Result<Object> saveGetMtHotelGoodsInventory(@RequestBody MtHotelGoodsInventoryParamVo mtHotelGoodsInventoryParamVo) {
        int goodsId = mtHotelGoodsInventoryParamVo.getGoodsId();
        int roomId = mtHotelGoodsInventoryParamVo.getRoomId();
        String startDate = mtHotelGoodsInventoryParamVo.getStartDate();
        String endDate = mtHotelGoodsInventoryParamVo.getEndDate();

        //时间参数为空 默认30天
        if (StringUtils.isEmpty(startDate)) {
            startDate = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
            endDate = DateUtil.formatDate(DateUtil.addDay(new Date(), 30), "yyyy-MM-dd");
        }
        return mtHotelGoodsService.getMtHotelGoodsInventory(goodsId, roomId, startDate, endDate);
    }

    @PostMapping("/getMtInventoryByGoodsIdAndRoomId")
    @ApiOperation(value = "查询库表产品库存信息接口根据产品id和房型id", notes = "必须经过auth授权")
    public Result<Object> getMtInventoryByGoodsIdAndRoomId(@RequestBody Map map) {
        Integer goodsId = (Integer) map.get("goodsId");
        Integer roomId = (Integer) map.get("roomId");
        return mtHotelGoodsService.getMtInventoryByGoodsIdAndRoomId(goodsId, roomId);
    }

    /**
     * 返回房态给 携程
     * @param mtHotelGoodsStatusParamVo
     * @return
     */
    @PostMapping("/getMtHotelGoodsStatus")
    @ApiOperation(value = "查询产品实时房态信息接口", notes = "必须经过auth授权")
    public Result<Object> getMtHotelGoodsStatus(@RequestBody MtHotelGoodsStatusParamVo mtHotelGoodsStatusParamVo) {
        //查询产品实时房态,接口地址:https://developer-distribution.meituan.com/distribution-open-platform/#/apiDocs/1/13/24
        Long hotelId = mtHotelGoodsStatusParamVo.getHotelId();
        Integer goodsType = mtHotelGoodsStatusParamVo.getGoodsType();
        String checkInDate = mtHotelGoodsStatusParamVo.getCheckinDate();
        /*if(null == checkInDate){
            return new Result<>("checkInDate不可为空",CommonConstants.REQUEST_ERROR);
        }*/
        String checkOutDate = mtHotelGoodsStatusParamVo.getCheckoutDate();
        /*if(null == checkOutDate){
            return new Result<>("checkOutDate不可为空",CommonConstants.REQUEST_ERROR);
        }*/
        //时间参数为空 默认30天
        if (StringUtils.isEmpty(checkInDate)) {
            checkInDate = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
            checkOutDate = DateUtil.formatDate(DateUtil.addDay(new Date(), 30), "yyyy-MM-dd");
        }
        return mtHotelGoodsService.getMtHotelGoodsStatus(hotelId, checkInDate, checkOutDate, goodsType, null);
    }

//    /**
//     * 返回房态 给飞猪
//     * @param callbackChangeGoodsDetailVo
//     * @return
//     */
//    @PostMapping("/getMtHotelGoodsStatusForFp")
//    @ApiOperation(value = "查询产品实时房态信息接口给飞猪", notes = "必须经过auth授权")
//    public Result<Object> getMtHotelGoodsStatusForFp(@RequestBody CallbackChangeGoodsDetailVo callbackChangeGoodsDetailVo) {
//        log.info("callbackChangeGoodsDetailVo飞猪房态="+GsonUtils.GsonString(callbackChangeGoodsDetailVo));
//        /*String checkInDate=DateUtil.formatDate(new Date(), "yyyy-MM-dd");
//        String checkOutDate=DateUtil.formatDate(DateUtil.addDay(new Date(), 30), "yyyy-MM-dd");*/
//        String startDate = callbackChangeGoodsDetailVo.getStartDate();
//        String endDate = callbackChangeGoodsDetailVo.getEndDate();
//        Map map = new HashMap();
//        if(null != callbackChangeGoodsDetailVo && callbackChangeGoodsDetailVo.getGoodsIdList().size()>0){
//            for (String gid:callbackChangeGoodsDetailVo.getGoodsIdList()){
//                map.put(gid,gid);
//            }
//        }
//        Result rs = mtHotelGoodsService.getMtHotelGoodsStatus(Long.valueOf(callbackChangeGoodsDetailVo.getHotelId()), startDate, endDate, 1, null);
//        if(rs.getCode()==CommonConstants.SUCCESS){
//            MtHotelGoodsStatusVo mtHotelGoodsStatusVo = (MtHotelGoodsStatusVo)rs.getData();
//            List<MtHotelGoodsStatusDetailVo> goodsStatusesNew = new ArrayList<>();
//            if(null != mtHotelGoodsStatusVo.getGoodsStatuses() && mtHotelGoodsStatusVo.getGoodsStatuses().size()>0){
//                for(MtHotelGoodsStatusDetailVo st: mtHotelGoodsStatusVo.getGoodsStatuses()){
//                    if(null != map.get(String.valueOf(st.getGoodsId()))){
//                        goodsStatusesNew.add(st);
//                    }
//                }
//                if(goodsStatusesNew.size()>0){
//                    mtHotelGoodsStatusVo.setGoodsStatuses(goodsStatusesNew);
//                }
//            }
//            return new Result<>(mtHotelGoodsStatusVo);
//        }
//        return new Result<>();
//    }
    /**
     * 内部外放接口
     *
     * @return
     */
    @PostMapping("/getMtHotelGoodsStatusBydays")
    @ApiOperation(value = "查询产品实时房态信息根据天数", notes = "必须经过auth授权")
    public Result<Object> aspgetMtHotelGoodsStatus(@RequestBody JSONObject jsonObject) {
        Long hotelId = jsonObject.getLong("hotelId");
        if (null == hotelId) {
            return new Result<>("hotelId不可为空", CommonConstants.REQUEST_ERROR);
        }
        Integer days = jsonObject.getInteger("days");
        String checkInDate = null;
        String checkOutDate = null;
        if (null != days) {
            checkInDate = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
            checkOutDate = DateUtil.formatDate(DateUtil.addDay(new Date(), days), "yyyy-MM-dd");
        } else {
            checkInDate = jsonObject.getString("startDate");
            checkOutDate = jsonObject.getString("endDate");
            if (StringUtils.isEmpty(checkInDate)) {
                return new Result<>("startDate不可为空", CommonConstants.REQUEST_ERROR);
            }
            if (StringUtils.isEmpty(checkOutDate)) {
                return new Result<>("endDate不可为空", CommonConstants.REQUEST_ERROR);
            }
        }
        Integer goodsType = MtHotelEnums.goodsTypeEnum.oneDay.getCode();
        Result result = mtHotelGoodsService.getMtHotelGoodsStatus(hotelId, checkInDate, checkOutDate, goodsType, null);
        if (result.getCode() == CommonConstants.SUCCESS) {
            MtHotelGoodsStatusVo mtHotelGoodsStatusVo = (MtHotelGoodsStatusVo) result.getData();
            if (null != mtHotelGoodsStatusVo) {
                List<MtHotelGoodsStatusDetailVo> goodsStatuses = mtHotelGoodsStatusVo.getGoodsStatuses();
                if (null != goodsStatuses && goodsStatuses.size() > 0) {
                    Map<Integer, List<MtHotelGoodsStatusDetailStateVo>> map = new HashMap<>();
                    for (MtHotelGoodsStatusDetailVo vo : goodsStatuses) {
                        map.put(vo.getGoodsId(), vo.getGoodsStatuses());
                    }
                    return new Result<>(map);
                }
            } else {
                return new Result<>(new HashMap());
            }
        }
        return new Result<>("error", CommonConstants.REQUEST_ERROR);
    }

    @PostMapping("/getMtHotelGoodsInventoryByDays")
    @ApiOperation(value = "查询产品库存信息接口根据天数", notes = "必须经过auth授权")
    public Result<Object> aspgetMtHotelGoodsInventoryByDays(@RequestBody JSONObject jsonObject) {
        log.info("查询产品库存信息接口根据天数 getMtHotelGoodsInventoryByDays:{}", JSON.toJSONString(jsonObject));
        Integer goodsId = jsonObject.getInteger("goodsId");
        if (null == goodsId) {
            return new Result<>("goodsId不可为空", CommonConstants.REQUEST_ERROR);
        }
        Integer roomId = jsonObject.getInteger("roomId");
        if (null == roomId) {
            return new Result<>("roomId不可为空", CommonConstants.REQUEST_ERROR);
        }
        Integer days = jsonObject.getInteger("days");
        String startDate = null;
        String endDate = null;
        if (null != days) {
            startDate = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
            endDate = DateUtil.formatDate(DateUtil.addDay(new Date(), days), "yyyy-MM-dd");
        } else {
            startDate = jsonObject.getString("startDate");
            endDate = jsonObject.getString("endDate");
            if (StringUtils.isEmpty(startDate)) {
                return new Result<>("startDate不可为空", CommonConstants.REQUEST_ERROR);
            }
            if (StringUtils.isEmpty(endDate)) {
                return new Result<>("endDate不可为空", CommonConstants.REQUEST_ERROR);
            }
        }
        Result result = mtHotelGoodsService.getMtHotelGoodsInventory(goodsId, roomId, startDate, endDate);
        log.info("查询产品库存信息接口根据天数 getMtHotelGoodsInventoryByDays 返回：{}", JSON.toJSONString(result));
        return result;
    }

    /**
     * 根据房型id获取数据库中该房型的所有产品
     * 根据房型id获取该房型底下所有产品
     */
    @PostMapping("/getMtGoodsByRoomId")
    @ApiOperation(value = "根据房型id获取数据库中该房型的所有产品", notes = "必须经过auth授权")
    public Result<List<MtHotelGoodsDto>> getMtGoodsByRoomId(@RequestBody JSONObject jsonObject) {
        Integer roomId = jsonObject.getInteger("roomId");//为真实的realRoomId
        Integer mtHotelId = jsonObject.getInteger("mtHotelId");
        if (ObjectUtils.isEmpty(roomId) || roomId < 1) {
            return new Result<>("美团的房型id不合法");
        }
        if (ObjectUtils.isEmpty(roomId) || roomId < 1) {
            return new Result<>("美团的酒店id不合法");
        }
        return mtHotelGoodsService.getMtGoodsByRoomId(String.valueOf(mtHotelId), String.valueOf(roomId));
    }

    /**
     * 用途：处理产品异步通知定时器调用
     * 根据房型id获取数据库中该房型的所有产品
     * 根据房型id获取该房型底下所有产品
     */
    @PostMapping("/saveDealGoodsFromJob")
    @ApiOperation(value = "处理产品异步通知方法", notes = "必须经过auth授权")
    public Result<Object> saveDealGoodsFromJob(@RequestBody Map map) {
        log.info(" 进入  处理产品异步通知方法 saveDealGoodsFromJob  map:{}", JSON.toJSONString(map));
        String goodsStr = (String) map.get("goods");
        if (null == goodsStr || goodsStr.equals("")) {
            return new Result<>("goods is null");
        }
        List<MtHotelGoodsCallbackVo> goods = JSON.parseArray(goodsStr, MtHotelGoodsCallbackVo.class);
        return mtHotelGoodsService.saveDealGoodsFromJob(goods);
    }

    /**
     * 静态产品校验是否存在失效新增等 (并且将接口返回的最新产品信息保存到队列，等待另一个定时器pop消费队列，进行产品最新数据保存到数据库)
     *
     *
     * @param map
     * @return
     */
    @PostMapping("/findMtGoodsCheckUpDown")
    @ApiOperation(value = "静态产品校验是否存在失效新增等", notes = "必须经过auth授权")
    public Result<Object> findMtGoodsCheckUpDown(@RequestBody Map map) {
        log.info("进入controller findMtGoodsCheckUpDown，timestamp={}",map.get("timestamp"));
        String timestamp = (String)map.get("timestamp");//每次定时器调用接口传唯一timestamp，为了方便查询线程日志

        int countTaskOneSecond = 1;//每一秒1次  默认时间未来30天   每次20家酒店

        Integer hotelNum = 10;//因为限流等问题 20改成10
        if(null != redisService.get("sw_check_hotels_num")){
            hotelNum = (Integer) redisService.get("sw_check_hotels_num");
        }
        for (int k = 0; k < countTaskOneSecond; k++) {
            List<String> tenHotelGoodsJSONArray = new ArrayList<>();//{"1268524":{"15049543":"7526236","15049541":"7526241","642498824":"7526241","15049538":"7526234","646384543":"7526236","662103444":"7526234","5557692":"2435773","52630":"8601202","52631":"516608","649032879":"516604","52627":"2435773","52628":"8601202","642315160":"8601202","642488012":"7526238","52626":"516604"}}
            for (int j = 0; j < hotelNum; j++) {
                String oneHotelGoodsMapJson = (String)redisService.RPop(MeituanConstants.REDIS_BASIC_GOODS_INFO_QUEUE_HOTELS);
                if(!ObjectUtils.isEmpty(oneHotelGoodsMapJson)){
                    tenHotelGoodsJSONArray.add(oneHotelGoodsMapJson);
                }else{
                    //已无hotelid，判断list中有无待处理数据，发起异步线程，调用第三方接口
                    if(null != tenHotelGoodsJSONArray && tenHotelGoodsJSONArray.size()>0){
                       //meituanFindMtGoodsCheckUpDownTask.executeFindMtGoodsCheckUpDown(tenHotelGoodsJSONArray,timestamp+"_"+k+"_"+j);
                        executeFindMtGoodsCheckUpDown(tenHotelGoodsJSONArray,timestamp+"_"+k+"_"+j);
                    }
                    log.info("{} executeFindMtGoodsCheckUpDown 当前coutTask，酒店处理完且酒店队列无数据： k={},j={}",timestamp,k,j);
                    return new Result<>();//return 结束当前
                }
                if(tenHotelGoodsJSONArray.size()==hotelNum){
                    log.info("{} executeFindMtGoodsCheckUpDown 十家执行一次 检查上架的美团酒店是否存在上下线 ： k={},j={}",timestamp,k,j);
                    //meituanFindMtGoodsCheckUpDownTask.executeFindMtGoodsCheckUpDown(tenHotelGoodsJSONArray,timestamp+"_"+k+"_"+j);
                    executeFindMtGoodsCheckUpDown(tenHotelGoodsJSONArray,timestamp+"_"+k+"_"+j);
                    tenHotelGoodsJSONArray = new ArrayList<>();
                }
            }
        }
        log.info("executeFindMtGoodsCheckUpDown {} 静态产品信息更新定时器 结束时间 {},countTaskOneSecond={}",timestamp,DateUtil.getCurrTime(),countTaskOneSecond);

        return new Result();

    }

    @Autowired
    private MtHotelRoomNameService mtHotelRoomNameService;
    //@Async 标识这个方法异步执行，可返回void或Future
    public void executeFindMtGoodsCheckUpDown(List<String> manyUpHotelsGoodsJsonList,String timestampIndex) {//传入20个酒店，内部再分成10个酒店
        log.info("进入manyUpHotelsJsonList={}",GsonUtils.GsonString(manyUpHotelsGoodsJsonList));

        //构建酒店ids集合
        List<Long> hotelIdsArray = new ArrayList<>();
        for (String oneHotelGoodsJson:manyUpHotelsGoodsJsonList){
            Map<String,Map<String,String>> oneHotelMap = GsonUtils.GsonToMaps(oneHotelGoodsJson);
            String thisMtHotelId = null;
            for (Map.Entry one:oneHotelMap.entrySet()){
                thisMtHotelId = (String)one.getKey();
                //遍历携程上架的美团酒店
                /* if(null != redisService.get(expkey+thisMtHotelId)){
                    log.info(timestampIndex+" findMtGoodsCheckUpDown 该酒店最近1小时内校验过产品 hotelId={}",thisMtHotelId);
                 }*/
                log.info("executeFindMtGoodsCheckUpDown thisMtHotelId={}",thisMtHotelId);
                hotelIdsArray.add(Long.valueOf(thisMtHotelId));
            }
        }
        log.info("进入 总 酒店待查询数量={},hotelIdsArray={}",manyUpHotelsGoodsJsonList.size(),hotelIdsArray.size());


        //酒店详情和物理房型支持20个酒店，但是rp接口只支持10个酒店
        Result manyHotelsRoomInfosResult = mtHotelRoomNameService.getMtHotelRoom(hotelIdsArray);
        if(manyHotelsRoomInfosResult.getCode()!=CommonConstants.SUCCESS){
            log.info("请求物理房型接口失败：hotelIdsArray={},manyHotelsRoomInfosResult={}",GsonUtils.GsonString(hotelIdsArray),GsonUtils.GsonString(manyHotelsRoomInfosResult));
            return;
        }
        Map<Long,List<MtHotelRealRoomVo>> oneHotelRoomInfosDataArray = (Map<Long,List<MtHotelRealRoomVo>>)manyHotelsRoomInfosResult.getData();
        if(null == oneHotelRoomInfosDataArray){
            oneHotelRoomInfosDataArray = new HashMap<>();
        }else{
            //对从物理房型接口中查询到的都进行realroomid的获取，并将酒店查询到的数据缓存到缓存中。！！！！！！！！！！！
            for (Map.Entry h:oneHotelRoomInfosDataArray.entrySet()){
                Long hotelid = (Long)h.getKey();
                List<MtHotelRealRoomVo> list = (List<MtHotelRealRoomVo>)h.getValue();
                if(null != list && list.size()>0){
                    redisService.setUnit(CommonConstants.SWITCH_MT_ONE_HOTEL_ROOMS_REDIS+String.valueOf(hotelid),GsonUtils.GsonString(list),1L, TimeUnit.DAYS);
                    redisService.lPush(CommonConstants.SWITCH_MT_HOTELS_LAST_REQ_ROOMS,String.valueOf(hotelid));//2021-04-14 qyy 校验房型信息定时器会用到
                }
            }

        }
        //查询酒店详情
        Map<String, MtHotelDetailVo> hotelsMap = new HashMap<>();
        List<MtHotelDetailVo> hotelDetailArray = mtHotelRoomNameService.returnHotelDetailRoomList(hotelIdsArray);//调用获取酒店详情数据的接口
        if(null != hotelDetailArray && hotelDetailArray.size()>0){
            for (MtHotelDetailVo h:hotelDetailArray){
                hotelsMap.put(String.valueOf(h.getBaseInfo().getHotelId()),h);
                if(null != h.getBaseInfo()){
                    redisService.setUnit(CommonConstants.SWITCH_MT_HOTEL_DETAIL_INFO_DATA_JOB_PUSH+h.getBaseInfo().getHotelId(),GsonUtils.GsonString(h),1L, TimeUnit.DAYS);
                }
            }
        }else{
            log.info("请求酒店详情接口异常 数据为空：hotelIdsArray={}",GsonUtils.GsonString(hotelIdsArray));
            return;
        }
        if(hotelDetailArray.size()!=hotelIdsArray.size()){
            log.info("请求酒店详情接口异常 查询酒店数量不等于，size={},size={},hotelDetailArray={}，hotelIdsArray={}",hotelDetailArray.size(),hotelIdsArray.size(),GsonUtils.GsonString(hotelDetailArray),GsonUtils.GsonString(hotelIdsArray));
        }
        Integer sleep=  2000;
        if(null != redisService.get("mtfp_controller_goods_down_check_sleep")){
            sleep = (Integer) redisService.get("mtfp_controller_goods_down_check_sleep");
        }
        log.info("manyUpHotelsJsonList={}",manyUpHotelsGoodsJsonList);
        if(manyUpHotelsGoodsJsonList.size()>10){
            List<String> tenUpHotelsJsonList = new ArrayList<>();
            for (int i = 0; i < manyUpHotelsGoodsJsonList.size()-1; i++) {
                String oneHotelGoods = manyUpHotelsGoodsJsonList.get(i);
                tenUpHotelsJsonList.add(oneHotelGoods);
                if(tenUpHotelsJsonList.size()==10){
                    log.info("tenUpHotelsJsonList11={}，i={}",tenUpHotelsJsonList,i);
                    //executTenHotels(oneHotelRoomInfosDataArray,hotelsMap,tenUpHotelsJsonList,timestampIndex);
                    meituanFindMtGoodsCheckUpDownTask.executTenHotels(oneHotelRoomInfosDataArray,hotelsMap,tenUpHotelsJsonList,timestampIndex);
                    tenUpHotelsJsonList = new ArrayList<>();
                    try {
                        Thread.sleep(sleep);
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                    }
                }else if(new BigDecimal(i).compareTo(new BigDecimal(manyUpHotelsGoodsJsonList.size()-1))==0 && tenUpHotelsJsonList.size()>0){
                    log.info("tenUpHotelsJsonList22={},i={}",tenUpHotelsJsonList,i);
                    //executTenHotels(oneHotelRoomInfosDataArray,hotelsMap,tenUpHotelsJsonList,timestampIndex);
                    meituanFindMtGoodsCheckUpDownTask.executTenHotels(oneHotelRoomInfosDataArray,hotelsMap,tenUpHotelsJsonList,timestampIndex);
                }
            }
        }else{
            log.info("manyUpHotelsJsonList00={}",manyUpHotelsGoodsJsonList);
            //executTenHotels(oneHotelRoomInfosDataArray,hotelsMap,manyUpHotelsGoodsJsonList,timestampIndex);
            meituanFindMtGoodsCheckUpDownTask.executTenHotels(oneHotelRoomInfosDataArray,hotelsMap,manyUpHotelsGoodsJsonList,timestampIndex);
        }

    }


    /**
     * 定时器消费保存 更新最保存新产品信息到数据库
     * @return
     */
    @PostMapping("/popBasicSaveMtGoodsInfoJob")
    @ApiOperation(value = "保存更新产品静态信息到数据库", notes = "必须经过auth授权")
    public Result<Object> popBasicSaveMtGoodsInfoJob() {
        String tenHotelGoodsVoStr = (String)redisService.RPop(MeituanConstants.REDIS_QUEUE_SAVE_BASIC_HOTEL_GOODS_INFO);//多个酒店请求rp接口，返回酒店集合附带产品信息 2小时静态是20个酒店一批次
        MtHotelGoodsVo manyHotelGoodsData = GsonUtils.GsonToBean(tenHotelGoodsVoStr,MtHotelGoodsVo.class);
        if(null != manyHotelGoodsData){
            mtHotelGoodsService.saveMtGoodsData(null,manyHotelGoodsData);
        }
        return new Result<>();
    }

    /**
     * 单独接口，校验上送最多10个酒店产品，是否存在失效，则返回失效产品  --->>  上架前简单校验 只校验产品是否存在：不需要校验房型id和早餐，因为上架时候获取到的就是最新的信息，并且也会判断是否全日房
     * @param mtHotelGoodsCheckFailVo
     * @return
     */
    @PostMapping("/checkTenHotelsGoodsFailure")
    @ApiOperation(value = "校验多个酒店的上架产品是否存在失效产品", notes = "必须经过auth授权")
    public Result<Object> checkTenHotelsGoodsFailure(@RequestBody MtHotelGoodsCheckFailVo mtHotelGoodsCheckFailVo) {
        return mtHotelGoodsService.checkTenHotelsGoodsFailure(mtHotelGoodsCheckFailVo);
    }

    /***
    * @Author: lmf
    * @Date: 2021/1/11
     * 主动查询统计一个礼拜房态的变化接口
    */
    @PostMapping("/statisWeekStatusDataList")
    @ApiOperation(value = "统计一个礼拜房态的变化接口",notes = "必须经过auth授权")
    public Result<List<MtHotelPriceStatisLog>> statisWeekStatusDataList(@RequestBody StatisLogVo statisLogVo){
        log.info("==========请求美团的统计数据开始,请求的类型为{}===========",statisLogVo.getGenre());
        return mtHotelPriceStatisLogService.statisWeekRooomDataList(statisLogVo.getGenre());
    }

    /***
    * @Author: lmf
    * @Date: 2021/1/18
     * 封装房态价格数据
    */
    @PostMapping("/addStatisDataLog")
    @ApiOperation(value = "统计一个礼拜房态的变化接口",notes = "必须经过auth授权")
    public Result<List<MtHotelPriceStatisLog>> addStatisDataLog(@RequestBody StatisLogVo statisLogVo){
        log.info("==========请求美团的统计数据开始,请求的类型为{}===========",statisLogVo.getGenre());
        return mtHotelPriceStatisLogService.addStatisDataLog(statisLogVo);
    }

    /**
     * 查询统计美团产品价格标准  过去三天的异步价格统计；（需考量：当前该方法执行统计比较久 1-2分钟）
     * @return
     */
    @PostMapping("/statMtGoodsPriceLibraryCallback")
    @ApiOperation(value = "统计美团产品价格标准,过去三天的异步价格统计,并更新标准价缓存", notes = "必须经过auth授权")
    public Result<Object> statMtGoodsPriceLibraryCallback() {
        meituanGoodsPriceLibraryCallbackTask.executeStatPriceLibrary();
        return new Result<>();
    }
//
//    /**
//     * 再次查询指定酒店本周的标准价
//     * @return
//     */
//    @PostMapping("/resetWeekLibraryPriceHotels")
//    @ApiOperation(value = "统计美团产品价格标准,过去三天的异步价格统计,并更新标准价缓存", notes = "必须经过auth授权")
//    public Result<Object> resetWeekLibraryPriceHotels() {
//        meituanGoodsPriceLibraryCallbackTask.resetWeekLibraryPriceHotels();
//        return new Result<>();
//    }
}
